def f(n):
    return 2**n if n< 3 else f(n-1) +f(n-2) + f(n-3)

def s(n):
    return f(n) + sum((f(i)*f(n-1-i) for i in range(n)))

print s(30)